home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / applic1a / form.frm < prev    next >
Text File  |  1999-09-14  |  3KB  |  75 lines

  1. VERSION 5.00
  2. Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
  3. Begin VB.Form Form1 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Internet Update"
  6.    ClientHeight    =   930
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   2730
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   930
  14.    ScaleWidth      =   2730
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin InetCtlsObjects.Inet Inet1 
  17.       Left            =   0
  18.       Top             =   120
  19.       _ExtentX        =   1005
  20.       _ExtentY        =   1005
  21.       _Version        =   393216
  22.    End
  23.    Begin VB.CommandButton Command1 
  24.       Caption         =   "Check for update"
  25.       Height          =   465
  26.       Left            =   600
  27.       TabIndex        =   0
  28.       Top             =   240
  29.       Width           =   1455
  30.    End
  31. End
  32. Attribute VB_Name = "Form1"
  33. Attribute VB_GlobalNameSpace = False
  34. Attribute VB_Creatable = False
  35. Attribute VB_PredeclaredId = True
  36. Attribute VB_Exposed = False
  37. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  38.  
  39. Private Function HyperJump(ByVal URL As String) As Long
  40.     HyperJump = ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus)
  41. End Function
  42.  
  43. Private Sub Command1_Click()
  44. 'This function assume files "application.ver", "news.txt" and "application.zip"
  45. 'on server http://server.com/user (change "server.com/user" by your server name and path)
  46. 'Inspect contain of files "news.txt" and "application.ver" at examples
  47. Dim Version As String, News As String
  48.     On Error GoTo ErrorMessage
  49.     Me.MousePointer = 11
  50.     'now assign content of file application.ver to variable Version
  51.     Version = Inet1.OpenURL("http://server.com/user/application.ver")
  52.     'You can try this function on Your local disk, but You must change adresses:
  53.     'for example: "file://c:\path\application.ver"
  54.     If Version = "" Then GoTo Skip 'if file not found or file is empty then exit
  55.     If Version <= App.Major & "." & App.Minor Then
  56.         MsgBox "No newer version was released.", vbInformation
  57.         GoTo Skip
  58.     End If
  59.     'now display MessageBox with news in newer version(s) of application and two buttons Yes(update), No(end)
  60.     News = Inet1.OpenURL("http://server.com/user/news.txt")
  61.     If MsgBox(Mid(News, 1, InStr(1, News, App.Major & "." & App.Minor) - 9), vbYesNo, "You can update from version " & App.Major & "." & App.Minor & " to version " & Version) = vbYes Then
  62.         HyperJump "http://server.com/user/application.zip" 'this will run default download manager (probable also open default browser)
  63.     End If
  64. Skip:
  65.     Me.MousePointer = 0
  66.     Exit Sub
  67. ErrorMessage:
  68.     Me.MousePointer = 0
  69.     MsgBox "An error has occured. Update failed." & Chr(10) & "You must download new version of this application manually at http://server.com.", vbCritical
  70. End Sub
  71.  
  72. Private Sub Form_Load()
  73.     Me.Caption = "Internet Update " & App.Major & "." & App.Minor
  74. End Sub
  75.